using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

using DataAccess;
using DataTransferObject;

namespace Business
{
    public enum SachHongBUSResult
    {
        OK,
        MAHONGERROR,
        TENHONGCERROR,
        TIENPHATAMERROR, //Tiền phạt < 0.
        DAOERROR
    }

    public class clsSachHongBUS
    {
        //Fields.
        private clsSachHongDAO SachHongDAO;

        //Constructors.
        public clsSachHongBUS()
        {
            this.SachHongDAO = new clsSachHongDAO();
        }

        #region Methods

        public long LayTienPhatTheoMaLoaiHong(String MaHong)
        {
            return SachHongDAO.LayTienPhatTheoMaLoaiHong(MaHong);
        }

        public SachHongBUSResult KiemTraRong(clsSachHongDTO obj)
        {
            if (obj.MaHong == "")
                return SachHongBUSResult.MAHONGERROR;
            if ((obj.TenHong == ""))
                return SachHongBUSResult.TENHONGCERROR;
            return SachHongBUSResult.OK;
        }

        public SachHongBUSResult KiemTraTienPhat(clsSachHongDTO obj)
        {
            if (obj.TienPhat < 0)
                return SachHongBUSResult.TIENPHATAMERROR; //Tiền phạt < 0.
            return SachHongBUSResult.OK;
        }

        public DataTable DanhSachSachHong()
        {
            return this.SachHongDAO.SelectAll();
        }

        public DataTable ThongKeSachBiHong(clsSachHongDTO obj)
        {
            return this.SachHongDAO.LayThongKeSachHong(obj);
        }

        public SachHongBUSResult ThemSachHong(clsSachHongDTO obj)
        {
            if (!this.SachHongDAO.Insert(obj))
                return SachHongBUSResult.DAOERROR;
            return SachHongBUSResult.OK;
        }

        public SachHongBUSResult SuaSachHong(clsSachHongDTO obj)
        {
            if (!this.SachHongDAO.Update(obj))
                return SachHongBUSResult.DAOERROR;
            return SachHongBUSResult.OK;
        }

        public SachHongBUSResult XoaSachHong(clsSachHongDTO obj)
        {
            if (!this.SachHongDAO.Delete(obj))
                return SachHongBUSResult.DAOERROR;
            return SachHongBUSResult.OK;
        }
        #endregion
    }
}
